home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Programming / LEDA / source / src / plane / _point_set.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-16  |  1.8 KB  |  87 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA  3.1c
  4. +
  5. +
  6. +  _point_set.c
  7. +
  8. +
  9. +  Copyright (c) 1994  by  Max-Planck-Institut fuer Informatik
  10. +  Im Stadtwald, 6600 Saarbruecken, FRG     
  11. +  All rights reserved.
  12. *******************************************************************************/
  13.  
  14.  
  15.  
  16. #include <LEDA/point_set.h>
  17. #include <LEDA/d2_dictionary.h>
  18.  
  19.  
  20. typedef d2_dictionary<double,double,DT_item>* d2_dic_ptr;
  21.  
  22. #define TTT (*d2_dic_ptr(ptr))
  23.  
  24. ps_item  Point_Set::insert(point p, void* i) 
  25. { ps_item it = delaunay_tree::insert(p,i);
  26.   TTT.insert(p.xcoord(),p.ycoord(),it);
  27.   return it;
  28.  }
  29.  
  30. list<point> Point_Set::all_points()
  31. { list<point> result;
  32.   list<ps_item>  L = all_items();
  33.   ps_item it;
  34.   forall(it,L) result.append(key(it));
  35.   return result;
  36. }
  37.  
  38.  
  39. ps_item Point_Set::lookup(point p)
  40. { double    x  = p.xcoord();
  41.   double    y  = p.ycoord();
  42.   dic2_item it = TTT.lookup(x,y);
  43.   return (it!=nil) ? TTT.inf(it) : nil;
  44. }
  45.  
  46. list<ps_item> Point_Set::range_search(double x0, double x1, double y0, double y1)
  47. {
  48.   list<dic2_item> Lr = TTT.range_search(x0,x1,y0,y1);
  49.  
  50.   list<ps_item> Lp;
  51.  
  52.   dic2_item it;
  53.  
  54.   forall(it,Lr) Lp.append(TTT.inf(it));
  55.  
  56.   return Lp;
  57.  
  58. }
  59.  
  60.  
  61. list<ps_item> Point_Set::all_items()          
  62. { list<DT_item> L; 
  63.   delaunay_tree::all_items(L); 
  64.   return *(list<ps_item>*)&L;
  65.  }
  66.  
  67.  
  68. list<ps_item> Point_Set::convex_hull()
  69. { list<DT_item> L; 
  70.   delaunay_tree::convex_hull(L);
  71.   return *(list<ps_item>*)&L;
  72.  }
  73.  
  74. void Point_Set::del(point p)
  75. { delaunay_tree::del(p);
  76.   TTT.del(p.xcoord(),p.ycoord());
  77.  }
  78.  
  79. void Point_Set::clear() { TTT.clear(); delaunay_tree::clear();  }
  80.  
  81. int  Point_Set::size()  { return TTT.size(); }
  82.  
  83. Point_Set::Point_Set()  { ptr = new d2_dictionary<double,double,DT_item>; }
  84.  
  85. Point_Set::~Point_Set() { delete d2_dic_ptr(ptr); }
  86.